import errorFun from '../../util/errorFun';
import requestTimeOut from '../../util/requestTimeout';

Page({
    data: {
        nowDvdList: [],
    },
    onLoad (options) {
       this.getDvdDetail(options.resid);
    },
    getDvdDetail(dvdId){
        wx.showLoading({
            title: '加载中',
            mask: true
        })
        let timer = setTimeout(() => {
            requestTimeOut();
        },10000)
        wx.cloud.callFunction({
            name: "getIdDetail",
            data: {
                _id: dvdId
            }
        }).then(res => {
            wx.hideLoading();
            clearTimeout(timer);
            this.setData({
                nowDvdList: res.result.data[0]
            })
        }).catch(err => {
            errorFun(err);
        })
    },
    bindListClick (evt) {
        if (this.data.nowDvdList && this.data.nowDvdList != undefined) {
            let newNowList = JSON.stringify(this.data.nowDvdList);
            wx.navigateTo({
                url: `../index/index?nowDvdList=${newNowList}&nowIndex=${evt.currentTarget.dataset.index}`,
            })
        } else {
            requestTimeOut();
        }
    },
    handleMore(){
        console.log('更多');
    },
})